package June;

public class Test_22_2 {
    public static void main(String[] args) {
        PC asus = new PC("ASUS", 16, "512", "华硕");
        asus.printInfo();
        NotePad notePad = new NotePad("ASUS", 16, "512", "黑蓝色");
        notePad.printInfo();
    }
}

// 编写Computer类，包含CPU、内存、硬盘等属性，
// getDetails方法用于返回Computer的详细信息
// 编写PC子类，继承Computer类，添加特有属性【品牌brand
// 编写NotePad子类，继承Computer类，添加特有属性【演示color
// 编写printInfo类，在main方法中创建PC和NotePad对象，分别给对象中特有的属性赋值，
// 以及从Computer类继承的属性赋值，并使用方法并打印输出信息。

class Computer {
    private String CPU;
    private double Memory;
    private String HardDisk;

    public Computer(String CPU, double memory, String hardDisk) {
        this.CPU = CPU;
        Memory = memory;
        HardDisk = hardDisk;
    }

    public String getCPU() {
        return CPU;
    }

    public void setCPU(String CPU) {
        this.CPU = CPU;
    }

    public double getMemory() {
        return Memory;
    }

    public void setMemory(double memory) {
        Memory = memory;
    }

    public String getHardDisk() {
        return HardDisk;
    }

    public void setHardDisk(String hardDisk) {
        HardDisk = hardDisk;
    }

    public String getDetails() {
        return "CPU = " + CPU + "\t" + "内存 = " + Memory + "\t" + "硬盘 = " + HardDisk;
    }
}
class PC extends Computer {
    private String brand;

    public PC(String CPU, double memory, String hardDisk, String brand) {
        super(CPU, memory, hardDisk);
        this.brand = brand;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }
    public void printInfo() {
        System.out.println("PC信息 = ");
        System.out.println(getDetails() + " brand" + brand);
    }
}
class NotePad extends Computer {
    private String color;

    public NotePad(String CPU, double memory, String hardDisk, String color) {
        super(CPU, memory, hardDisk);
        this.color = color;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
    public void printInfo() {
        System.out.println("NotePad = ");
        System.out.println(getDetails() + " NotePad:" + color);
    }
}

